﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ActionAndFun
{
    public class ActionAndFuncBase
    {
        /// <summary>
        /// 没有参数的系统泛型委托
        /// </summary>
        public void Test()
        {
            Action action = () => Console.WriteLine("大家好");
            Action<string> action1 = (name) => Console.WriteLine("我们正在和常老师学习上位机开发");

            Action<string, string> action2 = (name, course) => Console.WriteLine($"{name}正在讲解{course}");

            //调用
            action();
            action1("常老师");
            action2("常老师", "智能上位机开发高级技术");
        }
        /// <summary>
        /// 有参数的系统泛型委托
        /// </summary>
        public void Test1()
        {
            Func<int, int, double> myFunc1 = (a, b) => a + b;
            Func<int> myFunc2 = () =>
            {
                int a = 10;
                int b = 20;
                return a + b;
            };
            Console.WriteLine(myFunc1(10,20));
            Console.WriteLine(myFunc2());
        }
    }
}
